{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### In this notebook, I will be following the post in the [blog](http://r2rt.com/recurrent-neural-networks-in-tensorflow-i.html)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The taks is that given a sequence of input $X_t$, predict output $Y_t$.\n",
    "\n",
    "$X_t$'s are iid Bernouli random variable.\n",
    "\n",
    "$Y_t$ is also a binary random variable but its probability distribution depend on $X_t$.\n",
    "- If $X_{t - 3} = 0$ and $X_{t - 8} = 0$, probability of $Y_t = 1$ is $0.5$. \n",
    "- If $X_{t - 3} = 0$ and $X_{t - 8} = 1$, probability of $Y_t = 1$ is $0.25$.\n",
    "- If $X_{t - 3} = 1$ and $X_{t - 8} = 0$, probability of $Y_t = 1$ is $1.0$.\n",
    "- If $X_{t - 3} = 1$ and $X_{t - 8} = 1$, probability of $Y_t = 1$ is $0.75$."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The probability of the output is $1$ is \n",
    "$$P(Y = 1) = 0.25\\times (0.5 + 0.25 + 1 + 0.75) = 0.625$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The cross-entropy loss that we should expect in this case can be calculated as following: "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If our model does not learn any time dependencies, the error we will get will be approxiamtely equal to \n",
    "$$\n",
    "- P(Y = 1) \\log P(\\hat{Y} = 1) - P(Y = 0) \\log P(\\hat{Y} = 0) \n",
    "= \n",
    "-0.625 \\log(0.625) - 0.375 \\log(0.375) \n",
    "= 0.6615\n",
    "$$ "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If our model learns the first time-dependencies, then it will predict the target is $1$ based on the third input. \n",
    "\\begin{eqnarray}\n",
    "P(X_{-3} = 0) \\left(- P(Y = 1 | X_{-3} = 0) \\log P(\\hat{Y} = 1 | X_{-3} = 0) - P(Y = 0 | X_{-3} = 0) \\log P(\\hat{Y} = 0 | X_{-3} = 0)\\right) + P(X_{-3} = 1) \\left(- P(Y = 1 | X_{-3} = 1) \\log P(\\hat{Y} = 1 | X_{-3} = 1) - P(Y = 0 | X_{-3}   1) \\log P(\\hat{Y} = 0 | X_{-3} = 1)\\right) \\\\\n",
    "= 0.5 \\left(- 0.375 \\log(0.375) - 0.625 \\log(0.625) \\right) + 0.5 \\left(- 0.875 \\log(0.875) - 0.125 \\log(0.125) \\right) \\\\\n",
    "= 0.52\n",
    "\\end{eqnarray}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If our model learns both the time-dependencies, then the cross entropy error we will get is\n",
    "$$\n",
    "0.25 \\left(\\log(0.5) + \\left(-0.25 \\log(0.25) - 0.75 \\log(0.75)\\right) + 0 + \\left(-0.25 \\log(0.25) - 0.75 \\log(0.75)\\right)\\right)\n",
    "= 0.45445\n",
    "$$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import tensorflow as tf\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Input"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "batch_size = 200\n",
    "data_size = 1000000\n",
    "num_classes = 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def gen_data(data_size=data_size):\n",
    "    \"\"\"Return the X and Y sequence generated according the rule described\n",
    "    above\n",
    "    \"\"\"\n",
    "    x = np.random.choice(2, size=(data_size,))\n",
    "    y = []\n",
    "    for i in xrange(data_size):\n",
    "        threshold = 0.5\n",
    "        if x[i - 3] == 1:\n",
    "            threshold += 0.5\n",
    "        if x[i - 4] == 1:\n",
    "            threshold -= 0.25\n",
    "        if np.random.rand() > threshold:\n",
    "            y.append(0)\n",
    "        else:\n",
    "            y.append(1)\n",
    "    return x, np.array(y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "def gen_batch(raw_data, batch_size, num_steps):\n",
    "    \"\"\"Return a generator for producing the input sequence and target sequence for rnn\n",
    "    \"\"\"\n",
    "    x, y = raw_data\n",
    "    \n",
    "    size = len(x)\n",
    "    column_size = size // batch_size\n",
    "    \n",
    "    data_x = np.zeros((batch_size, column_size), dtype = np.int32)\n",
    "    data_y = np.zeros((batch_size, column_size), dtype = np.int32)\n",
    "    \n",
    "    for i in xrange(batch_size):\n",
    "        data_x[i] = x[i * column_size:(i + 1) * column_size]\n",
    "        data_y[i] = y[i * column_size:(i + 1) * column_size]\n",
    "        \n",
    "    num_epochs = column_size // num_steps\n",
    "    \n",
    "    for i in xrange(num_epochs):\n",
    "        x = data_x[:, i * num_steps:(i + 1) * num_steps]\n",
    "        y = data_y[:, i * num_steps:(i + 1) * num_steps]    \n",
    "        yield (x, y)\n",
    "        \n",
    "def gen_epoch(n, batch_size, num_steps):\n",
    "    \"\"\"Return a generator that gives data for N epochs\n",
    "    \"\"\"\n",
    "    for i in xrange(n):\n",
    "        data = gen_data()\n",
    "        yield gen_batch(data, batch_size, num_steps)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "#### Testing for an Epoch \n",
    "epoch = gen_epoch(1, data_size, 1)\n",
    "batches = next(epoch)\n",
    "batch = next(batches)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The average ones in Xs are 0.500602\n",
      "The average ones in Ys are 0.625322\n"
     ]
    }
   ],
   "source": [
    "#### The amount of one in ys should be close to 0.66\n",
    "#### The amount of one in xs should be close to 0.5 \n",
    "print \"The average ones in Xs are {}\".format((batch[0] == 1).mean())\n",
    "print \"The average ones in Ys are {}\".format((batch[1] == 1).mean())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### RNN model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "def create_variables(state_size, num_classes):\n",
    "    \"\"\"Create variables for RNN\n",
    "    \"\"\"\n",
    "    with tf.variable_scope(\"rnn\"):\n",
    "        W = tf.get_variable(\"W\", [num_classes + state_size, state_size])\n",
    "        b = tf.get_variable(\"b\", [state_size], initializer=tf.constant_initializer(0))\n",
    "    \n",
    "    with tf.variable_scope(\"softmax\"):\n",
    "        W_softmax = tf.get_variable(\"W_softmax\", [state_size, num_classes])\n",
    "        b_softmax = tf.get_variable(\"b_softmax\", [num_classes], \n",
    "                                   initializer=tf.constant_initializer(0))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def rnn(input_, state, state_size, num_classes):\n",
    "    \"\"\" Creating a model for RNN\n",
    "    \"\"\"\n",
    "    with tf.variable_scope(\"rnn\", reuse=True):\n",
    "        W = tf.get_variable(\"W\", [num_classes + state_size, state_size], \n",
    "                            initializer=tf.truncated_normal_initializer())\n",
    "        b = tf.get_variable(\"b\", [state_size], initializer=tf.constant_initializer(0))\n",
    "        return tf.tanh(tf.matmul(tf.concat(1, [input_, state]), W) + b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def rnn_loop(rnn_inputs, init_state, state_size, num_classes):\n",
    "    state = init_state\n",
    "    outputs = []\n",
    "    for x in rnn_inputs:\n",
    "        state = rnn(x, state, state_size, num_classes)\n",
    "        outputs.append(state)\n",
    "    return outputs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def softmax(outputs, state_size, num_classes):\n",
    "    with tf.variable_scope(\"softmax\", reuse=True):\n",
    "        W_softmax = tf.get_variable(\"W_softmax\", [state_size, num_classes])\n",
    "        b_softmax = tf.get_variable(\"b_softmax\", [num_classes], \n",
    "                                   initializer=tf.constant_initializer(0))\n",
    "        logits = [tf.matmul(o, W_softmax) + b_softmax for o in outputs]\n",
    "        probabilities = [tf.nn.softmax(l) for l in logits]\n",
    "    return logits\n",
    "            "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def loss(logits, y_target):\n",
    "    return tf.reduce_mean([tf.nn.sparse_softmax_cross_entropy_with_logits(l, y_target[:, i])\n",
    "            for i, l in enumerate(logits)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "def train(n_epoch=1, batch_size=200, num_steps=10, learning_rate=0.1, state_size=5):\n",
    "    \n",
    "    #### create placeholders\n",
    "    x_input = tf.placeholder(tf.int32, shape=(batch_size, num_steps))\n",
    "    y_target = tf.placeholder(tf.int32, shape=(batch_size, num_steps))\n",
    "    init_state = tf.placeholder(tf.float32, shape=(batch_size, state_size))   \n",
    "    x_one_hot = tf.one_hot(x_input, num_classes)\n",
    "    rnn_inputs = tf.unpack(x_one_hot, axis=1)\n",
    "\n",
    "    # Parameters for RNN\n",
    "    init_state_value = np.zeros((batch_size, state_size))\n",
    "    \n",
    "    #creating the model\n",
    "    create_variables(state_size, num_classes)\n",
    "    outputs = rnn_loop(rnn_inputs, init_state, state_size, num_classes)\n",
    "    final_state = outputs[-1]\n",
    "    training_loss = loss(softmax(outputs, state_size, num_classes), y_target)\n",
    "    train_op = tf.train.AdamOptimizer(learning_rate=learning_rate).minimize(training_loss)\n",
    "\n",
    "    #Training the model\n",
    "    #with tf.Session() as sess:\n",
    "    sess.run(tf.initialize_all_variables())\n",
    "    losses = []\n",
    "\n",
    "    for itr_epoch, epoch in enumerate(gen_epoch(n_epoch, batch_size=batch_size, num_steps=num_steps)):\n",
    "        print \"EPOCH: {}\".format(itr_epoch)\n",
    "        for itr_batch, (_x, _y) in enumerate(epoch): \n",
    "            init_state_value, loss_, _ = sess.run([final_state, training_loss, train_op], \n",
    "                                                  {x_input: _x, y_target: _y, init_state: init_state_value})\n",
    "            if itr_batch % 100 == 0:\n",
    "                losses.append(loss_)\n",
    "                \n",
    "    return losses\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "EPOCH: 0\n",
      "EPOCH: 1\n",
      "EPOCH: 2\n",
      "EPOCH: 3\n",
      "EPOCH: 4\n"
     ]
    }
   ],
   "source": [
    "sess = tf.InteractiveSession()\n",
    "losses = train(n_epoch=5, learning_rate=0.001, state_size=5, num_steps=12)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x7f2d302aafd0>]"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAEACAYAAABfxaZOAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XmcVOWV//HPaRYVUEBREFRcAIkLiiISJT876iCJRoyT\nmYAzMauSCBqzjGA02mbVjDEmIy4YNSY6khhHRfMyYtSOL9waFdlsaBRFQFRQUERlPb8/niopmu6u\npW/Vrar7fb9e9aLq1l2eLqpOPXWe555r7o6IiCRDTdwNEBGR0lHQFxFJEAV9EZEEUdAXEUkQBX0R\nkQRR0BcRSZCcgr6ZjTazhWbWZGaTWnh+NzObbmYvmtk8M/tartuKiEjpWLZ5+mZWAzQBJwFvALO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/plain": [
       "<matplotlib.figure.Figure at 0x7f2d36c3f710>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(losses)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "softmax_W, softmax_b = tf.get_collection(\"variables\", scope=\"softmax\")[0:2]\n",
    "softmax_W = softmax_W.eval()\n",
    "softmax_b = softmax_b.eval()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "rnn_W, rnn_b =  tf.get_collection(\"variables\", scope=\"rnn\")[0:2]\n",
    "rnn_W = rnn_W.eval()\n",
    "rnn_b = rnn_b.eval()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Input parameters\n",
    "num_steps = 12\n",
    "batch_size = 1\n",
    "state_size = 5\n",
    "def test(xs):\n",
    "    x_input = tf.placeholder(tf.int32, shape=(batch_size, num_steps))\n",
    "    y_target = tf.placeholder(tf.int32, shape=(batch_size, num_steps))\n",
    "    init_state = tf.placeholder(tf.float32, shape=(batch_size, state_size))   \n",
    "    x_one_hot = tf.one_hot(x_input, num_classes)\n",
    "    rnn_inputs = tf.unpack(x_one_hot, axis=1)\n",
    "\n",
    "    # Parameters for RNN\n",
    "    init_state_value = np.zeros((batch_size, state_size))\n",
    "\n",
    "    #creating the model\n",
    "    outputs = rnn_loop(rnn_inputs, init_state, state_size, num_classes)\n",
    "    final_state = outputs[-1]\n",
    "\n",
    "    #Testing the model\n",
    "    #with tf.Session() as sess:\n",
    "    states = []\n",
    "    for _x in xs: \n",
    "        init_state_value, states_ = sess.run([final_state, outputs], \n",
    "                                             {x_input: _x, init_state: init_state_value})\n",
    "        states.append(states_)\n",
    "    return states"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "def plot_test(states):\n",
    "    combined_states = np.concatenate([np.concatenate(state) for state in states])\n",
    "    plt.plot(combined_states)\n",
    "    plt.legend([\"state-0\", \"state-1\", \"state-2\", \"state-3\", \"state-4\"], loc=\"center\")\n",
    "    plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYkAAAEACAYAAABGYoqtAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHxNJREFUeJzt3XtwVfW99/H3N1yeI4VEErkKCWJQgRGVWjVa211QCraV\nesbW4BGs7XnAWw9DZ2yQ9oHA1ApnxhEZKQc83oCn6qm2laclRa1upUePqFys3CKiiAQQKxJoGQLm\n+/yxV+Im7EUS9jXJ5zWzZ9Za+5v1+/12IN+91m+t9TV3R0REJJG8bHdARERyl5KEiIiEUpIQEZFQ\nShIiIhJKSUJEREIpSYiISKiUJAkze9jM9prZ2yeJWWBm75rZejO7MBXtiohIeqXqSOJR4Jthb5rZ\nOOBsdx8CTAH+I0XtiohIGqUkSbj7X4D9JwkZDywNYl8HCsysTyraFhGR9MnUnMSZwM649V3BNhER\nyWGauBYRkVCdM9TOLmBg3PqAYNsJzEwPkxIRaSV3t3TsN5VHEha8ElkBTAIws8uAz9x9b9iO3L1d\nvmbNmpX1Pmh8Gp/G1/5e6ZSSIwkz+zUQAYrM7ENgFtAVcHdf4u4rzewaM9sG/B24JRXtiohIeqUk\nSbj7jS2IuTMVbYmISOZo4jqDIpFItruQVhpf26bxSSKW7vNZrWVmnmt9EhHJZWaGt4GJaxERaWeU\nJEREJJSShIiIhFKSEBGRUEoSIiISSklCRERCKUmIiEioTD3gr1XWlq3NdhdERIQcvZnus1c/y3Y3\nRETajNMvPz1tN9PlZJLItT6JiOQy3XEtIiJZoSQhIiKhlCRERCSUkoSIiIRKSZIws7FmtsX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rY5yuAz4ldjbUOWBuMoxB4\nIRjPc8DpcT9zN7GrEDYDY+K2fxn4azD+B7I9tgRj/TpfTFy3m/EBFxD7krIe+C2xq5va0/hmBX19\nm9iTmru05fEBvyb2FOkjxJLgLcQm5lMyHuB/EbtB+F1i84uDcmB87xK7AGFt8PpVJsenm+lERCRU\nrpxuEhGRHKQkISIioZQkREQklJKEiIiEUpIQEZFQShIiIhJKSUJEREIpSYiISKj/DwQqZAy3yZA+\nAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f2d083ce810>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYkAAAEACAYAAABGYoqtAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHcVJREFUeJzt3X10FfW97/H3FwjnQvNAQJ4hPOUigaMCt7Wip+0uWgqc\nVupdtASvYGlP0ao9LO5amkh7IbKqhLtWW+VKuWArKNwjtrRWzpEIdcEudFkrKqDlKSKFIgHqAxBU\nDgHyvX/sTdzAnkDYj0k+r7X2Ymb2b8/8fhOSz575zczP3B0REZF42mS6AiIikr0UEiIiEkghISIi\ngRQSIiISSCEhIiKBFBIiIhIoKSFhZmPNbJeZVZtZWZz3881stZltNbO3zOzbydiuiIikliV6n4SZ\ntQGqgZuBGmAzUOruu2LKPAjku/uDZnYVsBvo7u5nEtq4iIikVDKOJK4H3nb3/e5+GlgJTLigjAN5\n0ek84AMFhIhI9ktGSPQGDsTMvxtdFutxYKiZ1QDbgBlJ2K6IiKRYujquvwpscfdewAhgoZnlpmnb\nIiJyhdolYR0HgaKY+T7RZbGmAfMA3P0dM/srMAR47cKVmZkeJiUi0kTubqlYbzKOJDYDxWbWz8za\nA6XA6gvK7AduATCz7sBgYG/QCt29Rb7mzJmT8TqofWqf2tfyXqmU8JGEu581s/uAdURC55fuvtPM\n7oq87UuAHwPLzOzN6McecPcPE922iIik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[
       "<matplotlib.figure.Figure at 0x7f2d0814d4d0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYkAAAEACAYAAABGYoqtAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAF79JREFUeJzt3XtwlfWdx/HPNxJYMSSQlKuGm9FymSrSLhVdWqCagrsV\nnaFrYAWlnQWtnWWcHZsUW25TK+xst8qUUui0ItCKrV0rbUm1jtyc1npBsCIIiCLltrRcVSYB8t0/\nzkM8QH6QcG5PkveLeWbOec7vPM/ve8I5n/NczvMzdxcAAA3Jy3UHAADxRUgAAIIICQBAECEBAAgi\nJAAAQYQEACAoLSFhZj8xs/1m9sZ52swzs21mtsHMBqVjvQCAzErXlsRjkr4YetDMRku60t2vkjRF\n0o/StF4AQAalJSTc/UVJh87TZIykJVHbP0sqMrOu6Vg3ACBzsnVM4nJJu5Lu747mAQBijAPXAICg\nNllaz25JpUn3r4jmncPMuJgUADSRu1smlpvOLQmLpoaskDRRkszsekmH3X1/aEHu3iKnGTNm5LwP\n1Ed91NfypkxKy5aEmf1c0nBJJWb2vqQZktpKcndf5O4rzewWM9su6UNJk9KxXgBAZqUlJNx9fCPa\nfD0d6wIAZA8HrrNo+PDhue5CRlFf80Z9aIhlen9WU5mZx61PABBnZiZvBgeuAQAtDCEBAAgiJAAA\nQYQEACCIkAAABBESAIAgQgIAEERIAACCCAkAQBAhAQAIIiQAAEGEBAAgiJAAAAQREgCAIEICABBE\nSAAAgggJAEBQWsa4TjvLyABLAIAmYksCABBESAAAgmK5u8lWrcp1FwCg+RgxImOLZksCABBESAAA\ngggJAEAQIQEACCIkAABBhAQAIIiQAAAEERIAgCBCAgAQREgAAIIICQBAECEBAAgiJAAAQYQEACCI\nkAAABBESAIAgQgIAEERIAACCCAkAQBAhAQAIIiQAAEGEBAAgiJAAAAQREgCAoLSEhJmNMrMtZrbV\nzCobePzzZnbYzNZH07fSsV4AQGa1SXUBZpYn6QeSviBpj6RXzOwZd99yVtO17n5rqusDAGRPOrYk\nhkja5u473f2EpOWSxjTQztKwLgBAFqUjJC6XtCvp/l+jeWcbamYbzOx3ZjYgDesFAGRYyrubGuk1\nST3d/SMzGy3p15KuDrZevPjj24MGJSYAQMKGDYkpC8zdU1uA2fWSZrr7qOh+lSR397nnec67kj7t\n7gcbeMy1alVKfQKAVmXECLl7Rnbpp2N30yuSysysl5m1lVQhaUVyAzPrmnR7iBLhdE5AAADiJeXd\nTe5+ysy+Luk5JULnJ+6+2cymJB72RZLGmtm9kk5IOi7pjlTXCwDIvJR3N6Ubu5sAoIlivrsJANBC\nERIAgKBsnQILNKjd+PGq2bs3191ocdp1766an/88191AC0BIIKdq9u5V3I6LtQRmXOAA6cHuJgBA\nECEBAAgiJAAAQbE8JrFqRK57gGzhT505vI9aj0z+qdmSAJpo1qxZmjhxYqPbr1mzRqWlpSmts7a2\nVl/5yldUVFSkHj166Pvf/35KywMaK5ZbEkBL4u4pn200Y8YMvfPOO9q1a5f27NmjESNGaODAgSov\nL09TL4GGsSUBnMfcuXN1xRVXqLCwUP3799fKlSv13e9+V08++aQ6dOig6667TpK0ePFiDRgwQIWF\nhSorK9OiRYskSR999JFuueUW7dmzRx06dFBhYaH27dsnd9ecOXNUVlamzp07q6KiQocPHw72Y8mS\nJZo+fboKCwvVr18/TZ48WYuTL6kPZAghAQRs3bpV8+fP12uvvaajR4/q2WefVf/+/TVt2jTdcccd\nOnbsmF5//XVJUteuXbVy5UodPXpUjz32mO6//35t2LBB7du3V3V1tXr06KFjx47p6NGj6tatm+bN\nm6cVK1Zo3bp12rNnjzp16qSvfe1rDfbj8OHD2rt3r6655pr6eddee602bdqUldcBrRshgVgzS890\nMS655BLV1tbqzTff1MmTJ9WzZ0/16dOnwbajR49W7969JUnDhg1TeXm51q1bF1z2woUL9dBDD6l7\n9+7Kz8/X9OnT9dRTT6muru6cth988IHMTEVFRfXzCgsLdezYsYsrDG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uKElsG\nUpbqi0tINGtmViDpKUlT3f0DnTtId7M8O8DM/lnSfnffoPNfeqVZ1qfEt+vBkua7+2BJHyrx7ayl\n/P06KnEJnF5KbFVcZmb/phZS33mks57YnJJvZg9KOuHuT6RzsRdqEJeQ2C0p+QDKFdG82DOzNkoE\nxFJ3fyaavd/MukaPd5P0f9H83ZJKk55+us7Q/Fy7UdKtZrZD0hOSRprZUkn7Wkh9f5W0y91fje7/\nSonQaCl/v5sk7XD3g9G3xqcl3aCWU99p6ayn/jEzu0RSobsfzFzXG8fM7pZ0i6TxSbOzUl9cQqL+\nB3dm1laJfWgrctynxvqpEvv/Hk2at0LS3dHtuyQ9kzS/IjrDoI+kMkkvR5vIR8xsiJmZpIlJz8kZ\nd5/m7j3dva8Sf5MX3H2CpN+oZdS3X9IuM7s6mvUFJX7L0yL+fkrsZrrezP4h6tcXJL2l5l+f6cxv\nwOmsZ0W0DEn6sqQXMlZF2Bn1mdkoJXb53uruNUntslNfrg4+NXBAZpQSZwdtk1SV6/40ss83Sjql\nxNlYr0taH9VRLOn5qJ7nJHVMes43lTgLYbOk8qT5n1bi0uvbJD2a69oaqPXz+vjAdYupT9K1SnxJ\n2SDpf5U4u6kl1Tcj6usbkh5X4uzBZlufpJ9L2iOpRokQnKTEgfm01COpnaRfRPNfktQ7BvVtU+IE\nhPXR9MNs1seP6QAAQXHZ3QQAiCFCAgAQREgAAIIICQBAECEBAAgiJAAAQYQEACCIkAAABP0/tUr6\nczpFNeMAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f2ce9cf4550>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "xs1 = [np.ones((batch_size, num_steps)) for _ in range(1000)]\n",
    "xs2 = [np.zeros((batch_size, num_steps)) for _ in range(1000)]\n",
    "xs3 = [np.array([[1, 0, 0] * 4]) for _ in range(1000)]\n",
    "\n",
    "for xs in [xs1, xs2, xs3]:\n",
    "    plot_test(test(xs))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYYAAAEACAYAAAC3adEgAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAEuFJREFUeJzt3X/sXXd93/HnyzEZPxJMELITbBKgWRKKVliqBm8w9a4p\nxINSpxOtHDaaRNqWP0iLYKN2GFW+06YNT6oKVeg2l5QG1i4tgSkOgsaJktupEj+CkpCQfP2DpjOO\nQ4wYJVL5o0qs9/64J849X77X9pdzrr/Xvs+H9JXOOfd9P59zPra+r+/5nHvuSVUhSdLz1qz2DkiS\nZovBIElqMRgkSS0GgySpxWCQJLUYDJKkll6CIcmWJHuT7E+yfZnXX55kd5KHkzya5Lo++pUk9S9d\n72NIsgbYD1wJPAU8AGyrqr1jNTcBL6+qm5K8CtgHbKiq5zp1LknqXR9nDFcAB6rqYFU9C9wObF1S\nU8C5zfK5wP8zFCRpNvURDBuBQ2PrTzbbxt0C/HSSp4BvAh/ooV9J0hScqovPVwEPVdWrgX8IfDLJ\nOaeob0nSCqztoY3DwIVj65uabeOuB/4LQFX9VZK/Bi4DvrG0sSR+eZMkrVBVpa+2+jhjeAC4OMlF\nSc4GtgG7l9QcBH4RIMkG4BLgiUkNVpU/Vdx8882rvg+z8OM4OBaOxfF/+tb5jKGqjia5EdjDKGhu\nrarFJDeMXq5dwH8C/ijJI83bfquqftC1b0lS//qYSqKq/hy4dMm2/zG2/F1G1xkkSTPOO59n2GAw\nWO1dmAmOwwscixc4FtPT+Qa3viWpWdsnSZplSagZu/gsSTqDGAySpBaDQZLUYjBIkloMBklSi8Eg\nSWoxGCRJLQaDJKnFYJAktRgMkqQWg0GS1GIwSJJaDAZJUovBIElq6SUYkmxJsjfJ/iTbJ9QMkjyU\n5FtJ7u+jX0lS/zo/w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XJKzGd0Et3uV9+lU+EPg8ar6xNi23cB1zfK1wJ1j27c1n8x4HXAx8PVTtaPTUlUfqaoLq+r1\njP7d76uq9wF3MUfj8LxmmuBQkkuaTVcyuv9nrv5fMJpC2pzkxUnCaBweZ/7GIbTPpFd0/M100zNJ\nrmjG8dfH3jPZal95H7vavoXRJ3MOADtWe39OwfG+FTjK6BNYDwEPNmPwSuDeZiz2AK8Ye89NjD5t\nsAi8Y7WPYQpj8vO88KmkeR6HNzH6Y+lh4AuMPpU0d+MB3Nwc0yOMLrS+aJ7GAfgT4Cng7xgF5fXA\neSs9fuBnGT0i4QDwiZPp2xvcJEktszKVJEmaEQaDJKnFYJAktRgMkqQWg0GS1GIwSJJaDAZJUovB\nIElq+f+s13JMxhEd/AAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f2d086fe810>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# In the last example, all the time stamps that receives 1 input\n",
    "plt.plot(np.concatenate([t1[0] for t1 in t]))\n",
    "plt.plot(np.concatenate([t1[3] for t1 in t]))\n",
    "plt.plot(np.concatenate([t1[6] for t1 in t]))\n",
    "plt.plot(np.concatenate([t1[9] for t1 in t]))\n",
    "print "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYYAAAEACAYAAAC3adEgAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAADf1JREFUeJzt3V2sZeVdx/Hvjw6kLVUKRoaWAYqldGwvRIh0LDYcrYEB\nDaAhChpLuTDESDSNqYA2mXNjLBe+tEFDUKTQF0GryJRiHAgcDBciSie0dIAhFDoMML4UiEXb0OHv\nxV4w5xnOGeZ0rz17ndnfT7KTtdZ+9rOe9Z/J/p31tleqCkmSXnXItAcgSRoWg0GS1DAYJEkNg0GS\n1DAY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stQguG1m+CSHMboJrjNUx7TgfBXwNer6lOLlm0GPtpNXwLctmj5Rd2VGScCJwH/eqAGOilV9XtV\ndXxV/Qijf/e7q+rXgC8xQ3V4VXeYYEeSk7tFH2Z0/89M/b9gdAhpQ5I3JwmjOnyd2atDaPekV7T9\n3eGmF5Oc3tXxI4s+s7xpn3lfdLZ9I6Mrc7YDV057PAdge88AdjO6AusrwINdDY4C7upqsQV4+6LP\nXMXoaoNtwFnT3oYJ1ORM9lyVNMt1+DFGfyxtBf6e0VVJM1cPYFO3TQ8xOtF66CzVAfgC8AzwXUZB\neSlw5Eq3HziN0SMStgOf2p91e4ObJKkxlENJkqSBMBgkSQ2DQZLUMBgkSQ2DQZLUMBgkSQ2DQZLU\nMBgkSY3/BwtBPJQLBJj+AAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f2ce9a99650>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# In the last example, all the time stamps that receives 1 input\n",
    "for i in [1, 2, 4, 5, 7, 8, 10, 11]: \n",
    "    plt.plot(np.concatenate([t1[i] for t1 in t]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
